[gd_scene load_steps=9 format=2]

[ext_resource path="res://blokoj/kosmo/shaders/star1.gdshader" type="Shader" id=1]
[ext_resource path="res://blokoj/kosmo/resursoj/space_env.tres" type="Environment" id=2]
[ext_resource path="res://addons/SIsilicon.vfx.godrays/GodRays.gd" type="Script" id=3]
[ext_resource path="res://blokoj/kosmo/shaders/noise.png" type="Texture2D" id=4]


[sub_resource type="PlaneMesh" id=1]

[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 1 )
shader_param/iTime = null
shader_param/noise_freq = 10.0
shader_param/sun_color = Color( 1, 1, 0, 1 )
shader_param/Noise = ExtResource( 4 )

[sub_resource type="GDScript" id=3]
script/source = "extends MeshInstance3D
var iTime = 0.0
var cam
var mega_sun = false
var star_mat

func _ready():
	star_mat = get_surface_override_material(0)
	cam = get_tree().get_root().get_camera_3d() # получаем камеру
	#$Env.environment.background_sky.set_panorama($space_viewport.get_texture())
	$Env.environment.background_sky.set_panorama(load(\"res://resursoj/stelamapo_8k.jpg\"))
func _process(delta):
	iTime +=delta
	star_mat.set(\"shader_param/iTime\",iTime)
	rotation = cam.rotation + Vector3(PI/2,0,0)
	$light.look_at_from_position(get_global_transform().origin,cam.get_global_transform().origin,Vector3.UP);
	
func _on_HScrollBar_value_changed(value):
	#$space_viewport/space_texture.material.set(\"shader_param/noise_freq\",value)
	print(value)
"

[sub_resource type="SphereShape3D" id=4]

[node name="star1" type="MeshInstance3D"]
transform = Transform3D( 100, 0, 0, 0, 100, 0, 0, 0, 100, 0, 0, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
script = SubResource( 3 )

[node name="light" type="DirectionalLight3D" parent="."]

[node name="GodRays" type="Node3D" parent="light"]
script = ExtResource( 3 )
exposure = 0.1
attenuation = 2.0
light_size = 0.5

[node name="Env" type="WorldEnvironment" parent="."]
environment = ExtResource( 2 )

[node name="StaticBody3D" type="StaticBody3D" parent="."]

[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
shape = SubResource( 4 )

[node name="Control" type="Control" parent="."]
offset_right = 40.0
offset_bottom = 40.0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Label2" type="Label" parent="Control"]
offset_left = 408.696
offset_top = 491.868
offset_right = 472.696
offset_bottom = 505.868
text = "sun_noise"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="HScrollBar" type="HScrollBar" parent="Control/Label2"]
offset_left = 0.735092
offset_top = 16.1721
offset_right = 208.735
offset_bottom = 28.1721
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="value_changed" from="Control/Label2/HScrollBar" to="." method="_on_HScrollBar_value_changed"]
